package com.restkeeper.controller;

import com.restkeeper.dto.AliyunMessageDto;
import com.restkeeper.service.AliyunService;
import com.restkeeper.utils.Result;
import com.restkeeper.utils.ResultCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequestMapping("/aliyun")
@RestController
@RequiredArgsConstructor
public class AliyunController {

    private final AliyunService aliyunService;

    /**
     * 发送短信/语音
     */
    @PostMapping(value = "/send_sms")
    public Result sendSms(@RequestBody AliyunMessageDto dto){
        switch (dto.getSendKey()){
            case "alarm":return aliyunService.alarm(dto);
            default:return Result.error(ResultCode.message_type_null,"未匹配到消息类型");
        }
    }

}
